

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/myblog/img/fluid.png">
  <link rel="icon" href="/myblog/img/fluid.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="joelee">
  <meta name="keywords" content="">
  
    <meta name="description" content="一直期待在ubuntu 22.04 上实现平铺式窗口，所以有了此文章，记录我的探索。经过对比，选择轻量级窗口管理器dwm。在动手之前，先观看B站UP对dwm的安装和配置，还可以看ubuntu配置dwm。感觉dwm非常符合我对平铺式窗口管理器的想象，就是看到的博主都是用arch linux的，没有使用ubuntu实践过的。suckless极简桌面教程1。B站up主‘称呼我为c先生’、他的github">
<meta property="og:type" content="article">
<meta property="og:title" content="ubuntu_windowmanager">
<meta property="og:url" content="https://joelee-hit.github.io/joelee-hit.github.io/2024/05/16/ubuntu-windowmanager/index.html">
<meta property="og:site_name" content="joelee&#39;s blog">
<meta property="og:description" content="一直期待在ubuntu 22.04 上实现平铺式窗口，所以有了此文章，记录我的探索。经过对比，选择轻量级窗口管理器dwm。在动手之前，先观看B站UP对dwm的安装和配置，还可以看ubuntu配置dwm。感觉dwm非常符合我对平铺式窗口管理器的想象，就是看到的博主都是用arch linux的，没有使用ubuntu实践过的。suckless极简桌面教程1。B站up主‘称呼我为c先生’、他的github">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2024-05-15T16:13:26.000Z">
<meta property="article:modified_time" content="2024-05-17T02:38:42.384Z">
<meta property="article:author" content="joelee">
<meta property="article:tag" content="dwm">
<meta property="article:tag" content="window-manager">
<meta name="twitter:card" content="summary_large_image">
  
  
    <meta name="referrer" content="no-referrer-when-downgrade">
  
  
  <title>ubuntu_windowmanager - joelee&#39;s blog</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/myblog/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/myblog/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/myblog/css/highlight-dark.css" />
  




  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"joelee-hit.github.io","root":"/myblog/","version":"1.9.5-a","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":true,"follow_dnt":true,"baidu":null,"google":{"measurement_id":null},"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":"UU4TJ0JQzDgf0er5h2RfW8ve-gzGzoHsz","app_key":"px4eIsDZQBJRxIUkt6PCJpNH","server_url":"https://uu4tj0jq.lc-cn-n1-shared.com","path":"window.location.pathname","ignore_local":true}},"search_path":"/myblog/local-search.xml","include_content_in_search":true};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/myblog/js/utils.js" ></script>
  <script  src="/myblog/js/color-schema.js" ></script>
  

  

  
    <!-- Google tag (gtag.js) -->
    <script async>
      if (!Fluid.ctx.dnt) {
        Fluid.utils.createScript("https://www.googletagmanager.com/gtag/js?id=", function() {
          window.dataLayer = window.dataLayer || [];
          function gtag() {
            dataLayer.push(arguments);
          }
          gtag('js', new Date());
          gtag('config', '');
        });
      }
    </script>
  

  

  

  

  
    
  



  
<meta name="generator" content="Hexo 6.3.0"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 70vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/myblog/">
      <strong>joelee的记事本</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/myblog/">
                <i class="iconfont icon-home-fill"></i>
                <span>首页</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/myblog/archives/">
                <i class="iconfont icon-archive-fill"></i>
                <span>归档</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/myblog/categories/">
                <i class="iconfont icon-category-fill"></i>
                <span>分类</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/myblog/tags/">
                <i class="iconfont icon-tags-fill"></i>
                <span>标签</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/myblog/about/">
                <i class="iconfont icon-user-fill"></i>
                <span>关于</span>
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              <i class="iconfont icon-search"></i>
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">
              <i class="iconfont icon-dark" id="color-toggle-icon"></i>
            </a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/myblog/img/default.png') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="ubuntu_windowmanager"></span>
          
        </div>

        
          
  <div class="mt-3">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-author" aria-hidden="true"></i>
        joelee
      </span>
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2024-05-16 00:13" pubdate>
          2024年5月16日 凌晨
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          26k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          218 分钟
        
      </span>
    

    
    
      
        <span id="busuanzi_container_page_pv" style="display: none">
          <i class="iconfont icon-eye" aria-hidden="true"></i>
          <span id="busuanzi_value_page_pv"></span> 次
        </span>
        
      
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <h1 id="seo-header">ubuntu_windowmanager</h1>
            
              <p class="note note-info">
                
                  
                    本文最后更新于：2024年5月17日 上午
                  
                
              </p>
            
            
              <div class="markdown-body">
                
                <p>一直期待在ubuntu 22.04
上实现平铺式窗口，所以有了此文章，记录我的探索。经过对比，选择轻量级窗口管理器<a
target="_blank" rel="noopener" href="https://dwm.suckless.org/">dwm</a>。在动手之前，先观看<a
target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV11J411t7RY/?p=1&amp;t=1325">B站UP对dwm的安装和配置</a>，还可以看<a
target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/262067759">ubuntu配置dwm</a>。感觉dwm非常符合我对平铺式窗口管理器的想象，就是看到的博主都是用arch
linux的，没有使用ubuntu实践过的。<a
target="_blank" rel="noopener" href="https://cloud-atlas.readthedocs.io/zh-cn/latest/linux/desktop/suckless/index.html">suckless极简桌面教程1</a>。<a
target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1FT411Z7A7/?spm_id_from=..search-card.all.click">B站up主‘称呼我为c先生’</a>、<a
target="_blank" rel="noopener" href="https://github.com/yaocccc/dwm?tab=readme-ov-file">他的github
dwm仓库</a>。</p>
<h2 id="更新">更新</h2>
<p>应该先<code>make clean all</code>，再修改<code>config.h</code>，而不是直接修改<code>config.def.h</code></p>
<h2 id="dwm">dwm</h2>
<p>首先，下载dwm的源代码，据说代码非常小：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">git <span class="hljs-built_in">clone</span> https://git.suckless.org/dwm<br></code></pre></td></tr></table></figure>
<h3 id="readme">README</h3>
<p>查看<code>README</code>文件：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><code class="hljs c">Requirements<br>------------<br>In order to build dwm you need the Xlib header files.<br><br><br>Installation<br>------------<br>Edit config.mk to match your local <span class="hljs-title function_">setup</span> <span class="hljs-params">(dwm is installed into</span><br><span class="hljs-params">the /usr/local namespace by <span class="hljs-keyword">default</span>)</span>.<br><br>Afterwards enter the following command to build and install <span class="hljs-title function_">dwm</span> <span class="hljs-params">(<span class="hljs-keyword">if</span></span><br><span class="hljs-params">necessary as root)</span>:<br><br>    make clean install<br></code></pre></td></tr></table></figure>
<p>首先，<code>Xlib</code>头文件一般包含在开发包<code>libx11-dev</code>里，ubuntu22.04中的版本是<code>libx11-dev/jammy-updates,jammy-security,now 2:1.7.5-1ubuntu0.3 amd64</code>，直接用<code>apt</code>安装即可，安装后可以在<code>/usr/include/X11/</code>下找到相应头文件。</p>
<p>其次，<code>config.mk</code>是<code>dwm</code>源代码安装时的配置文件，这样编译后就会安装到相应文件夹（更加轻量、速度更快）。</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><code class="hljs c">Running dwm<br>-----------<br>Add the following line to your .xinitrc to start dwm using startx:<br><br>    exec dwm<br><br>In order to connect dwm to a specific display, make sure that<br>the DISPLAY environment variable is <span class="hljs-built_in">set</span> correctly, e.g.:<br><br>    DISPLAY=foo.bar:<span class="hljs-number">1</span> exec dwm<br><br>(This will start dwm on display :<span class="hljs-number">1</span> of the host foo.bar.)<br><br>In order to display status info in the bar, you can <span class="hljs-keyword">do</span> something<br>like this in your .xinitrc:<br><br>    <span class="hljs-keyword">while</span> xsetroot -name <span class="hljs-string">&quot;`date` `uptime | sed &#x27;s/.*,//&#x27;`&quot;</span><br>    <span class="hljs-keyword">do</span><br>    	sleep <span class="hljs-number">1</span><br>    done &amp;<br>    exec dwm<br><br><br>Configuration<br>-------------<br>The configuration of dwm is done by creating a custom config.h<br>and (re)compiling the source code.<br></code></pre></td></tr></table></figure>
<p>首先，<code>exec dwm</code>告诉<code>xinit</code>进程执行dwm作为X服务器的最后一个动作，即dwm将成为你的窗口管理器。<code>DISPLAY=foo.bar:1 exec dwm</code>用于在名为<code>foo.bar</code>的主机上的第二个显示器（<code>:1</code>）运行dwm。<code>while xsetroot ... exec dwm</code>用于在dwm的状态栏自定义信息，比如日期和系统运行时间。</p>
<p>其次，dwm的配置不是通过图形界面或单独的配置文件完成的，而是需要直接修改源代码中的<code>config.h</code>文件。这意味着如果你想调整dwm的行为，比如键绑定、颜色方案或是布局管理等，你需要编辑这个C头文件，然后重新编译dwm的源代码。这种配置方式虽然较为繁琐，但为用户提供极高的定制自由度。</p>
<h3 id="config.mk-makefile">config.mk &amp; makefile</h3>
<p>看<code>config.mk</code>文件：</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><code class="hljs makefile"><span class="hljs-comment"># dwm version</span><br>VERSION = 6.5<br><br><span class="hljs-comment"># Customize below to fit your system</span><br><br><span class="hljs-comment"># paths</span><br>PREFIX = /usr/local<br>MANPREFIX = $&#123;PREFIX&#125;/share/man<br><br>X11INC = /usr/X11R6/<span class="hljs-keyword">include</span><br>X11LIB = /usr/X11R6/lib<br><br><span class="hljs-comment"># Xinerama, comment if you don&#x27;t want it</span><br>XINERAMALIBS  = -lXinerama<br>XINERAMAFLAGS = -DXINERAMA<br><br><span class="hljs-comment"># freetype</span><br>FREETYPELIBS = -lfontconfig -lXft<br>FREETYPEINC = /usr/<span class="hljs-keyword">include</span>/freetype2<br><span class="hljs-comment"># OpenBSD (uncomment)</span><br><span class="hljs-comment">#FREETYPEINC = $&#123;X11INC&#125;/freetype2</span><br><span class="hljs-comment">#MANPREFIX = $&#123;PREFIX&#125;/man</span><br><br><span class="hljs-comment"># includes and libs</span><br>INCS = -I$&#123;X11INC&#125; -I$&#123;FREETYPEINC&#125;<br>LIBS = -L$&#123;X11LIB&#125; -lX11 $&#123;XINERAMALIBS&#125; $&#123;FREETYPELIBS&#125;<br><br><span class="hljs-comment"># flags</span><br>CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\<span class="hljs-string">&quot;$&#123;VERSION&#125;\&quot; $&#123;XINERAMAFLAGS&#125;</span><br><span class="hljs-string">#CFLAGS   = -g -std=c99 -pedantic -Wall -O0 $&#123;INCS&#125; $&#123;CPPFLAGS&#125;</span><br><span class="hljs-string">CFLAGS   = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os $&#123;INCS&#125; $&#123;CPPFLAGS&#125;</span><br><span class="hljs-string">LDFLAGS  = $&#123;LIBS&#125;</span><br><span class="hljs-string"></span><br><span class="hljs-string"># Solaris</span><br><span class="hljs-string">#CFLAGS = -fast $&#123;INCS&#125; -DVERSION=\&quot;$&#123;VERSION&#125;\&quot;</span><br><span class="hljs-string">#LDFLAGS = $&#123;LIBS&#125;</span><br><span class="hljs-string"></span><br><span class="hljs-string"># compiler and linker</span><br><span class="hljs-string">CC = cc</span><br><span class="hljs-string"></span><br></code></pre></td></tr></table></figure>
<p><code>PREFIX, MANPREFIX</code>是dwm的安装位置和man帮助文件所处位置，可以不用改。</p>
<p><code>X11INC, X11LIB</code>这里是过时的/usr/X11R6，应该改成<code>X11INC = /usr/include/X11</code>和<code>X11LIB = /usr/lib/x86_64-linux-gnu</code>。<code>/usr/lib/x86_64-linux-gnu</code>下有<code>libX11.so</code>等文件。<code>libx11-dev</code>。</p>
<p><code>Xinerama</code>是X
Window系统的一个扩展，它允许应用程序跨越多个物理显示器并将其视作单个逻辑屏幕，从而实现多屏拼接显示，头文件在包<code>libxinerama-dev</code>里。平常的笔记本可以不要。况且现代的显示器通常用<code>XRandR</code>？</p>
<p><code>FREETYPELIBS</code>和<code>FREETYPEINC</code>不用改变。FreeType是一个开源的、高质量、可移植的字体引擎库，它被设计为轻量级、高效并支持高度定制。<code>libfontconfig-dev</code>包含开发时需要的头文件和库，FontConfig是一个字体配置和定制库；<strong>libxft-dev</strong>:
Xft库是基于FreeType库的，专门用于在X Window系统中渲染字体。</p>
<blockquote>
<p>可以用<code>pkg-config</code>查询库和依赖文件，比如<code>pkg-config --cflags --libs x11</code>，查询<code>X11</code>的库、依赖、cflags。</p>
</blockquote>
<p>修改后的<code>config.mk</code>配置文件：</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br></pre></td><td class="code"><pre><code class="hljs makefile"><span class="hljs-comment"># dwm version</span><br>VERSION = 6.5<br><br><span class="hljs-comment"># Customize below to fit your system</span><br><br><span class="hljs-comment"># paths</span><br>PREFIX = /usr/local<br>MANPREFIX = $&#123;PREFIX&#125;/share/man<br><br><span class="hljs-comment"># X11INC = /usr/X11R6/include</span><br>X11INC = /usr/<span class="hljs-keyword">include</span>/X11<br><span class="hljs-comment"># X11LIB = /usr/X11R6/lib</span><br>X11LIB = /usr/lib/x86_64-linux-gnu<br><br><span class="hljs-comment"># Xinerama, comment if you don&#x27;t want it</span><br><span class="hljs-comment"># XINERAMALIBS  = -lXinerama</span><br><span class="hljs-comment"># XINERAMAFLAGS = -DXINERAMA</span><br><br><span class="hljs-comment"># freetype</span><br>FREETYPELIBS = -lfontconfig -lXft<br>FREETYPEINC = /usr/<span class="hljs-keyword">include</span>/freetype2<br><span class="hljs-comment"># OpenBSD (uncomment)</span><br><span class="hljs-comment">#FREETYPEINC = $&#123;X11INC&#125;/freetype2</span><br><span class="hljs-comment">#MANPREFIX = $&#123;PREFIX&#125;/man</span><br><br><span class="hljs-comment"># includes and libs</span><br>INCS = -I$&#123;X11INC&#125; -I$&#123;FREETYPEINC&#125;<br><span class="hljs-comment"># LIBS = -L$&#123;X11LIB&#125; -lX11 $&#123;XINERAMALIBS&#125; $&#123;FREETYPELIBS&#125;</span><br>LIBS = -L$&#123;X11LIB&#125; -lX11 $&#123;FREETYPELIBS&#125;<br><br><span class="hljs-comment"># flags</span><br><span class="hljs-comment"># CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\&quot;$&#123;VERSION&#125;\&quot; $&#123;XINERAMAFLAGS&#125;</span><br>CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\<span class="hljs-string">&quot;$&#123;VERSION&#125;\&quot;</span><br><span class="hljs-string">#CFLAGS   = -g -std=c99 -pedantic -Wall -O0 $&#123;INCS&#125; $&#123;CPPFLAGS&#125;</span><br><span class="hljs-string">CFLAGS   = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os $&#123;INCS&#125; $&#123;CPPFLAGS&#125;</span><br><span class="hljs-string">LDFLAGS  = $&#123;LIBS&#125;</span><br><span class="hljs-string"></span><br><span class="hljs-string"># Solaris</span><br><span class="hljs-string">#CFLAGS = -fast $&#123;INCS&#125; -DVERSION=\&quot;$&#123;VERSION&#125;\&quot;</span><br><span class="hljs-string">#LDFLAGS = $&#123;LIBS&#125;</span><br><span class="hljs-string"></span><br><span class="hljs-string"># compiler and linker</span><br><span class="hljs-string">CC = cc</span><br></code></pre></td></tr></table></figure>
<p>再看<code>makefile</code>文件：</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br></pre></td><td class="code"><pre><code class="hljs makefile"><span class="hljs-comment"># dwm - dynamic window manager</span><br><span class="hljs-comment"># See LICENSE file for copyright and license details.</span><br><br><span class="hljs-keyword">include</span> config.mk<br><br>SRC = drw.c dwm.c util.c<br>OBJ = $&#123;SRC:.c=.o&#125;<br><br><span class="hljs-section">all: dwm</span><br><br><span class="hljs-section">.c.o:</span><br>	$&#123;CC&#125; -c $&#123;CFLAGS&#125; <span class="hljs-variable">$&lt;</span><br><br><span class="hljs-section">$&#123;OBJ&#125;: config.h config.mk</span><br><br><span class="hljs-section">config.h:</span><br>	cp config.def.h <span class="hljs-variable">$@</span><br><br><span class="hljs-section">dwm: $&#123;OBJ&#125;</span><br>	$&#123;CC&#125; -o <span class="hljs-variable">$@</span> $&#123;OBJ&#125; $&#123;LDFLAGS&#125;<br><br><span class="hljs-section">clean:</span><br>	rm -f dwm $&#123;OBJ&#125; dwm-$&#123;VERSION&#125;.tar.gz<br><br><span class="hljs-section">dist: clean</span><br>	mkdir -p dwm-$&#123;VERSION&#125;<br>	cp -R LICENSE Makefile README config.def.h config.mk\<br>		dwm.1 drw.h util.h $&#123;SRC&#125; dwm.png transient.c dwm-$&#123;VERSION&#125;<br>	tar -cf dwm-$&#123;VERSION&#125;.tar dwm-$&#123;VERSION&#125;<br>	gzip dwm-$&#123;VERSION&#125;.tar<br>	rm -rf dwm-$&#123;VERSION&#125;<br><br><span class="hljs-section">install: all</span><br>	mkdir -p $&#123;DESTDIR&#125;$&#123;PREFIX&#125;/bin<br>	cp -f dwm $&#123;DESTDIR&#125;$&#123;PREFIX&#125;/bin<br>	chmod 755 $&#123;DESTDIR&#125;$&#123;PREFIX&#125;/bin/dwm<br>	mkdir -p $&#123;DESTDIR&#125;$&#123;MANPREFIX&#125;/man1<br>	sed <span class="hljs-string">&quot;s/VERSION/$&#123;VERSION&#125;/g&quot;</span> &lt; dwm.1 &gt; $&#123;DESTDIR&#125;$&#123;MANPREFIX&#125;/man1/dwm.1<br>	chmod 644 $&#123;DESTDIR&#125;$&#123;MANPREFIX&#125;/man1/dwm.1<br><br><span class="hljs-section">uninstall:</span><br>	rm -f $&#123;DESTDIR&#125;$&#123;PREFIX&#125;/bin/dwm\<br>		$&#123;DESTDIR&#125;$&#123;MANPREFIX&#125;/man1/dwm.1<br><br><span class="hljs-meta"><span class="hljs-keyword">.PHONY</span>: all clean dist install uninstall</span><br><br></code></pre></td></tr></table></figure>
<ol type="1">
<li>注释行，简要描述项目名称及版权和许可详情所在文件。</li>
<li>包含<code>config.mk</code>文件，该文件通常包含编译时的配置信息，比如编译器选项、安装路径等。</li>
<li>定义了需要编译的源文件列表。</li>
<li>将源文件列表转换为对应的对象文件列表。Makefile的模式替换功能，<code>$&#123;SRC:.c=.o&#125;</code>表示将<code>SRC</code>变量中每个源文件名的<code>.c</code>后缀替换为<code>.o</code>，相当于<code>OBJ = drw.o dwm.o util.o</code>。</li>
<li><code>all</code>目标：默认规则，用于构建最终的可执行文件<code>dwm</code>。</li>
<li>规则模板，用于将任何<code>.c</code>文件编译为<code>.o</code>（目标文件）。使用<code>$&#123;CC&#125;</code>编译器，并应用<code>$&#123;CFLAGS&#125;</code>编译选项。<code>$&lt;</code>表示第一个依赖项。</li>
<li><code>$&#123;OBJ&#125;: config.h config.mk</code>指出所有对象文件依赖于<code>config.h</code>和<code>config.mk</code>，这意味着每次这两个文件改变时，所有对象文件都需要重新编译。</li>
<li><code>config.h</code>的生成规则，简单地从<code>config.def.h</code>复制而来。<code>$@</code>是目标文件名，也就是<code>config.h</code>。</li>
<li><code>dwm</code>可执行文件的链接规则，将所有对象文件链接成最终的二进制文件。<code>$&#123;OBJ&#125;</code>表示该规则对应的依赖。</li>
<li><code>clean</code>目标：删除编译过程中产生的中间文件和可执行文件。</li>
<li><code>dist</code>目标：依赖于clean规则，因此会先执行clean，再创建项目的发布包，包括创建版本目录、复制必要文件、打包并压缩。</li>
<li><code>install</code>目标：安装编译好的dwm到系统中指定的位置（由<code>$&#123;PREFIX&#125;</code>和<code>$&#123;MANPREFIX&#125;</code>定义），并设置适当的权限。${DESTDIR}没有设置时通常为空字符串。<code>man1</code>
存放的是第1节的手册页，</li>
<li><code>uninstall</code>目标：从系统中卸载dwm及相关手册页。</li>
<li><code>.PHONY</code>指令，声明后面列出的目标为伪目标，意味着它们不会对应到文件，而总是执行指定的命令。</li>
</ol>
<p>这个不需要任何改动，不过需要理解。</p>
<h3 id="config.def.h">config.def.h</h3>
<p>由<code>makefile</code>文件可知，<code>config.h</code>是直接由<code>config.def.h</code>复制而来，所以我们需要关注<code>config.def.h</code>文件：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br></pre></td><td class="code"><pre><code class="hljs c"><span class="hljs-comment">/* See LICENSE file for copyright and license details. */</span><br><br><span class="hljs-comment">/* appearance */</span><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">unsigned</span> <span class="hljs-type">int</span> borderpx  = <span class="hljs-number">1</span>;        <span class="hljs-comment">/* border pixel of windows */</span><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">unsigned</span> <span class="hljs-type">int</span> snap      = <span class="hljs-number">32</span>;       <span class="hljs-comment">/* snap pixel */</span><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">int</span> showbar            = <span class="hljs-number">1</span>;        <span class="hljs-comment">/* 0 means no bar */</span><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">int</span> topbar             = <span class="hljs-number">1</span>;        <span class="hljs-comment">/* 0 means bottom bar */</span><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">char</span> *fonts[]          = &#123; <span class="hljs-string">&quot;monospace:size=10&quot;</span> &#125;;<br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">char</span> dmenufont[]       = <span class="hljs-string">&quot;monospace:size=10&quot;</span>;<br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">char</span> col_gray1[]       = <span class="hljs-string">&quot;#222222&quot;</span>;<br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">char</span> col_gray2[]       = <span class="hljs-string">&quot;#444444&quot;</span>;<br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">char</span> col_gray3[]       = <span class="hljs-string">&quot;#bbbbbb&quot;</span>;<br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">char</span> col_gray4[]       = <span class="hljs-string">&quot;#eeeeee&quot;</span>;<br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">char</span> col_cyan[]        = <span class="hljs-string">&quot;#005577&quot;</span>;<br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">char</span> *colors[][<span class="hljs-number">3</span>]      = &#123;<br>	<span class="hljs-comment">/*               fg         bg         border   */</span><br>	[SchemeNorm] = &#123; col_gray3, col_gray1, col_gray2 &#125;,<br>	[SchemeSel]  = &#123; col_gray4, col_cyan,  col_cyan  &#125;,<br>&#125;;<br><br><span class="hljs-comment">/* tagging */</span><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">char</span> *tags[] = &#123; <span class="hljs-string">&quot;1&quot;</span>, <span class="hljs-string">&quot;2&quot;</span>, <span class="hljs-string">&quot;3&quot;</span>, <span class="hljs-string">&quot;4&quot;</span>, <span class="hljs-string">&quot;5&quot;</span>, <span class="hljs-string">&quot;6&quot;</span>, <span class="hljs-string">&quot;7&quot;</span>, <span class="hljs-string">&quot;8&quot;</span>, <span class="hljs-string">&quot;9&quot;</span> &#125;;<br><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> Rule rules[] = &#123;<br>	<span class="hljs-comment">/* xprop(1):</span><br><span class="hljs-comment">	 *	WM_CLASS(STRING) = instance, class</span><br><span class="hljs-comment">	 *	WM_NAME(STRING) = title</span><br><span class="hljs-comment">	 */</span><br>	<span class="hljs-comment">/* class      instance    title       tags mask     isfloating   monitor */</span><br>	&#123; <span class="hljs-string">&quot;Gimp&quot;</span>,     <span class="hljs-literal">NULL</span>,       <span class="hljs-literal">NULL</span>,       <span class="hljs-number">0</span>,            <span class="hljs-number">1</span>,           <span class="hljs-number">-1</span> &#125;,<br>	&#123; <span class="hljs-string">&quot;Firefox&quot;</span>,  <span class="hljs-literal">NULL</span>,       <span class="hljs-literal">NULL</span>,       <span class="hljs-number">1</span> &lt;&lt; <span class="hljs-number">8</span>,       <span class="hljs-number">0</span>,           <span class="hljs-number">-1</span> &#125;,<br>&#125;;<br><br><span class="hljs-comment">/* layout(s) */</span><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">float</span> mfact     = <span class="hljs-number">0.55</span>; <span class="hljs-comment">/* factor of master area size [0.05..0.95] */</span><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">int</span> nmaster     = <span class="hljs-number">1</span>;    <span class="hljs-comment">/* number of clients in master area */</span><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">int</span> resizehints = <span class="hljs-number">1</span>;    <span class="hljs-comment">/* 1 means respect size hints in tiled resizals */</span><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">int</span> lockfullscreen = <span class="hljs-number">1</span>; <span class="hljs-comment">/* 1 will force focus on the fullscreen window */</span><br><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> Layout layouts[] = &#123;<br>	<span class="hljs-comment">/* symbol     arrange function */</span><br>	&#123; <span class="hljs-string">&quot;[]=&quot;</span>,      tile &#125;,    <span class="hljs-comment">/* first entry is default */</span><br>	&#123; <span class="hljs-string">&quot;&gt;&lt;&gt;&quot;</span>,      <span class="hljs-literal">NULL</span> &#125;,    <span class="hljs-comment">/* no layout function means floating behavior */</span><br>	&#123; <span class="hljs-string">&quot;[M]&quot;</span>,      monocle &#125;,<br>&#125;;<br><br><span class="hljs-comment">/* key definitions */</span><br><span class="hljs-meta">#<span class="hljs-keyword">define</span> MODKEY Mod1Mask</span><br><span class="hljs-meta">#<span class="hljs-keyword">define</span> TAGKEYS(KEY,TAG) \</span><br><span class="hljs-meta">	&#123; MODKEY,                       KEY,      view,           &#123;.ui = 1 &lt;&lt; TAG&#125; &#125;, \</span><br><span class="hljs-meta">	&#123; MODKEY|ControlMask,           KEY,      toggleview,     &#123;.ui = 1 &lt;&lt; TAG&#125; &#125;, \</span><br><span class="hljs-meta">	&#123; MODKEY|ShiftMask,             KEY,      tag,            &#123;.ui = 1 &lt;&lt; TAG&#125; &#125;, \</span><br><span class="hljs-meta">	&#123; MODKEY|ControlMask|ShiftMask, KEY,      toggletag,      &#123;.ui = 1 &lt;&lt; TAG&#125; &#125;,</span><br><br><span class="hljs-comment">/* helper for spawning shell commands in the pre dwm-5.0 fashion */</span><br><span class="hljs-meta">#<span class="hljs-keyword">define</span> SHCMD(cmd) &#123; .v = (const char*[])&#123; <span class="hljs-string">&quot;/bin/sh&quot;</span>, <span class="hljs-string">&quot;-c&quot;</span>, cmd, NULL &#125; &#125;</span><br><br><span class="hljs-comment">/* commands */</span><br><span class="hljs-type">static</span> <span class="hljs-type">char</span> dmenumon[<span class="hljs-number">2</span>] = <span class="hljs-string">&quot;0&quot;</span>; <span class="hljs-comment">/* component of dmenucmd, manipulated in spawn() */</span><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">char</span> *dmenucmd[] = &#123; <span class="hljs-string">&quot;dmenu_run&quot;</span>, <span class="hljs-string">&quot;-m&quot;</span>, dmenumon, <span class="hljs-string">&quot;-fn&quot;</span>, dmenufont, <span class="hljs-string">&quot;-nb&quot;</span>, col_gray1, <span class="hljs-string">&quot;-nf&quot;</span>, col_gray3, <span class="hljs-string">&quot;-sb&quot;</span>, col_cyan, <span class="hljs-string">&quot;-sf&quot;</span>, col_gray4, <span class="hljs-literal">NULL</span> &#125;;<br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">char</span> *termcmd[]  = &#123; <span class="hljs-string">&quot;st&quot;</span>, <span class="hljs-literal">NULL</span> &#125;;<br><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> Key keys[] = &#123;<br>	<span class="hljs-comment">/* modifier                     key        function        argument */</span><br>	&#123; MODKEY,                       XK_p,      spawn,          &#123;.v = dmenucmd &#125; &#125;,<br>	&#123; MODKEY|ShiftMask,             XK_Return, spawn,          &#123;.v = termcmd &#125; &#125;,<br>	&#123; MODKEY,                       XK_b,      togglebar,      &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>	&#123; MODKEY,                       XK_j,      focusstack,     &#123;.i = +<span class="hljs-number">1</span> &#125; &#125;,<br>	&#123; MODKEY,                       XK_k,      focusstack,     &#123;.i = <span class="hljs-number">-1</span> &#125; &#125;,<br>	&#123; MODKEY,                       XK_i,      incnmaster,     &#123;.i = +<span class="hljs-number">1</span> &#125; &#125;,<br>	&#123; MODKEY,                       XK_d,      incnmaster,     &#123;.i = <span class="hljs-number">-1</span> &#125; &#125;,<br>	&#123; MODKEY,                       XK_h,      setmfact,       &#123;.f = <span class="hljs-number">-0.05</span>&#125; &#125;,<br>	&#123; MODKEY,                       XK_l,      setmfact,       &#123;.f = +<span class="hljs-number">0.05</span>&#125; &#125;,<br>	&#123; MODKEY,                       XK_Return, zoom,           &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>	&#123; MODKEY,                       XK_Tab,    view,           &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>	&#123; MODKEY|ShiftMask,             XK_c,      killclient,     &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>	&#123; MODKEY,                       XK_t,      setlayout,      &#123;.v = &amp;layouts[<span class="hljs-number">0</span>]&#125; &#125;,<br>	&#123; MODKEY,                       XK_f,      setlayout,      &#123;.v = &amp;layouts[<span class="hljs-number">1</span>]&#125; &#125;,<br>	&#123; MODKEY,                       XK_m,      setlayout,      &#123;.v = &amp;layouts[<span class="hljs-number">2</span>]&#125; &#125;,<br>	&#123; MODKEY,                       XK_space,  setlayout,      &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>	&#123; MODKEY|ShiftMask,             XK_space,  togglefloating, &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>	&#123; MODKEY,                       XK_0,      view,           &#123;.ui = ~<span class="hljs-number">0</span> &#125; &#125;,<br>	&#123; MODKEY|ShiftMask,             XK_0,      tag,            &#123;.ui = ~<span class="hljs-number">0</span> &#125; &#125;,<br>	&#123; MODKEY,                       XK_comma,  focusmon,       &#123;.i = <span class="hljs-number">-1</span> &#125; &#125;,<br>	&#123; MODKEY,                       XK_period, focusmon,       &#123;.i = +<span class="hljs-number">1</span> &#125; &#125;,<br>	&#123; MODKEY|ShiftMask,             XK_comma,  tagmon,         &#123;.i = <span class="hljs-number">-1</span> &#125; &#125;,<br>	&#123; MODKEY|ShiftMask,             XK_period, tagmon,         &#123;.i = +<span class="hljs-number">1</span> &#125; &#125;,<br>	TAGKEYS(                        XK_1,                      <span class="hljs-number">0</span>)<br>	TAGKEYS(                        XK_2,                      <span class="hljs-number">1</span>)<br>	TAGKEYS(                        XK_3,                      <span class="hljs-number">2</span>)<br>	TAGKEYS(                        XK_4,                      <span class="hljs-number">3</span>)<br>	TAGKEYS(                        XK_5,                      <span class="hljs-number">4</span>)<br>	TAGKEYS(                        XK_6,                      <span class="hljs-number">5</span>)<br>	TAGKEYS(                        XK_7,                      <span class="hljs-number">6</span>)<br>	TAGKEYS(                        XK_8,                      <span class="hljs-number">7</span>)<br>	TAGKEYS(                        XK_9,                      <span class="hljs-number">8</span>)<br>	&#123; MODKEY|ShiftMask,             XK_q,      quit,           &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>&#125;;<br><br><span class="hljs-comment">/* button definitions */</span><br><span class="hljs-comment">/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */</span><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> Button buttons[] = &#123;<br>	<span class="hljs-comment">/* click                event mask      button          function        argument */</span><br>	&#123; ClkLtSymbol,          <span class="hljs-number">0</span>,              Button1,        setlayout,      &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>	&#123; ClkLtSymbol,          <span class="hljs-number">0</span>,              Button3,        setlayout,      &#123;.v = &amp;layouts[<span class="hljs-number">2</span>]&#125; &#125;,<br>	&#123; ClkWinTitle,          <span class="hljs-number">0</span>,              Button2,        zoom,           &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>	&#123; ClkStatusText,        <span class="hljs-number">0</span>,              Button2,        spawn,          &#123;.v = termcmd &#125; &#125;,<br>	&#123; ClkClientWin,         MODKEY,         Button1,        movemouse,      &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>	&#123; ClkClientWin,         MODKEY,         Button2,        togglefloating, &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>	&#123; ClkClientWin,         MODKEY,         Button3,        resizemouse,    &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>	&#123; ClkTagBar,            <span class="hljs-number">0</span>,              Button1,        view,           &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>	&#123; ClkTagBar,            <span class="hljs-number">0</span>,              Button3,        toggleview,     &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>	&#123; ClkTagBar,            MODKEY,         Button1,        tag,            &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>	&#123; ClkTagBar,            MODKEY,         Button3,        toggletag,      &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>&#125;;<br></code></pre></td></tr></table></figure>
<p>设置外观、布局、快捷键、标签、窗口规则、以及按钮行为。说明我们还需要安装dmenu（一个菜单图形界面）、st（一个轻量级终端模拟器）。</p>
<p><strong>外观</strong></p>
<ul>
<li><code>borderpx</code>: 窗口边框像素宽度。</li>
<li><code>snap</code>:
窗口对齐的像素点。当你尝试将一个窗口的边缘靠近屏幕边缘或另一个窗口时，一旦距离小于32像素，窗口会自动贴紧边缘或与相邻窗口对齐，而不是停留在一个随机的距离上。</li>
<li><code>showbar</code>: 是否显示状态栏，1为显示。</li>
<li><code>topbar</code>: 状态栏位置，1为顶部。</li>
<li><code>fonts</code>: 字体设置。</li>
<li><code>dmenufont</code>: <a
target="_blank" rel="noopener" href="https://tools.suckless.org/dmenu/">dmenu</a>使用的字体。dmenu是通常与dwm一起使用的可应用于脚本的图形选择界面程序，<a
target="_blank" rel="noopener" href="https://mainliufeng.github.io/2019/08/11/dmenu/">详细教程</a>。dmenu接受标准输入（可以是echo，也可以是任何其他脚本的输出），用换行分隔，打开一个图形菜单，将前n项显示出来；用户可以输入并搜索，用户输入回车后，dmenu返回用户选择的菜单项；或者用户按Esc，dmenu什么也不返回；或者用户输入一个和任何菜单项都不匹配的字符串，dmenu返回这个字符串。</li>
<li><code>col_gray1-4</code>, <code>col_cyan</code>: 颜色定义。</li>
<li><code>colors</code>:
配置正常和选中状态下的前景、背景和边框颜色。</li>
</ul>
<p><strong>标签</strong></p>
<ul>
<li><code>tags[]</code>: 定义了9个工作标签，每个标签对应一个数字。</li>
</ul>
<p><strong>规则(rules)</strong></p>
<ul>
<li><p>定义了一些特定应用程序的窗口行为，例如Gimp总是浮动，Firefox窗口被分配到特定的标签上。</p></li>
<li><p><code>xprop</code>是一个命令行工具，可以用来查看X窗口的属性（输入<code>xprop</code>后点击窗口），其中<code>WM_CLASS</code>和<code>WM_NAME</code>是两个关键属性，分别用于标识窗口的类（通常包括实例名和类别名）和窗口的标题。比如<code>xprop -name "typora" WM_CLASS WM_NAME</code>会返回：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs bash">WM_CLASS(STRING) = <span class="hljs-string">&quot;typora&quot;</span>, <span class="hljs-string">&quot;Typora&quot;</span><br>WM_NAME(STRING) = <span class="hljs-string">&quot;typora&quot;</span><br></code></pre></td></tr></table></figure></li>
<li><p><code>class</code>：匹配窗口的类名（窗口的<code>WM_CLASS</code>属性的第一部分，即实例名）。</p></li>
<li><p><code>instance</code>：匹配窗口的实例名（窗口的<code>WM_CLASS</code>属性的第二部分）。这里设置为<code>NULL</code>，意味着不关心实例名，只匹配基于类名。</p></li>
<li><p><code>title</code>：匹配窗口的标题（<code>WM_NAME</code>属性）。同样设置为<code>NULL</code>，表示不基于窗口标题进行匹配。</p></li>
<li><p><code>tags mask</code>：定义了窗口应归属的标签掩码。例如，<code>1 &lt;&lt; 8</code>（即<code>256</code>）意味着窗口将标记到第9个标签上（标签索引从0开始计数）；<code>0</code>表示不显式分配标签。</p></li>
<li><p><code>isfloating</code>：布尔值，决定窗口是否浮动。1表示浮动（不遵循平铺布局，可自由调整大小和位置），0表示窗口遵循布局管理。</p></li>
<li><p><code>monitor</code>：指定窗口应出现在哪个显示器上。-1表示自动选择，其他正整数指定了具体的显示器编号。</p></li>
</ul>
<p><strong>布局(layouts)</strong></p>
<ul>
<li><code>mfact</code>: 主区域占屏幕的比例。</li>
<li><code>nmaster</code>: 主区域中窗口数量。</li>
<li><code>layouts</code>:
支持的布局模式，包括平铺(<code>tile</code>)、浮动(<code>NULL</code>，即默认的无布局管理，窗口自由浮动)和单窗口全屏(<code>monocle</code>)。</li>
<li><code>&#123; "[]=", tile &#125;</code>：这是默认布局，符号为"[]=".
当选择此布局时，调用<code>tile</code>函数来排列窗口。这种布局会按照<code>mfact</code>和<code>nmaster</code>的设定，将一个或多个窗口放在主区域，并将剩余的窗口平铺在栈中区域。符号通常会在状态栏显示，让用户知道当前所选的布局模式。</li>
<li><code>&#123; "&gt;&lt;&gt;", NULL &#125;</code>：这个布局没有对应的排列函数，意味着它代表浮动布局。在这种模式下，窗口会忽略平铺规则，可以自由调整大小和位置，如同在传统的窗口管理模式中一样。符号为"&gt;&lt;&gt;"。</li>
<li><code>&#123; "[M]", monocle &#125;</code>：这是一种名为“monocle”的布局，符号为"[M]"。选择此布局时，所有窗口都会依次全屏显示，每次只显示一个窗口，适合需要专注于单一任务的场景。<code>monocle</code>函数负责实现这一布局逻辑。</li>
</ul>
<p><strong>键定义(keys)</strong></p>
<ul>
<li><p>定义了各种键盘快捷键，如打开dmenu、切换标签、调整窗口布局、控制窗口堆栈、聚焦窗口、移动窗口、调整主区域大小等。<code>XK_F4</code>表示MODKEY(alt键)+F4</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs c"><span class="hljs-comment">/* key definitions */</span><br><span class="hljs-meta">#<span class="hljs-keyword">define</span> MODKEY Mod1Mask</span><br><span class="hljs-meta">#<span class="hljs-keyword">define</span> TAGKEYS(KEY,TAG) \</span><br><span class="hljs-meta">	&#123; MODKEY,                       KEY,      view,           &#123;.ui = 1 &lt;&lt; TAG&#125; &#125;, \</span><br><span class="hljs-meta">	&#123; MODKEY|ControlMask,           KEY,      toggleview,     &#123;.ui = 1 &lt;&lt; TAG&#125; &#125;, \</span><br><span class="hljs-meta">	&#123; MODKEY|ShiftMask,             KEY,      tag,            &#123;.ui = 1 &lt;&lt; TAG&#125; &#125;, \</span><br><span class="hljs-meta">	&#123; MODKEY|ControlMask|ShiftMask, KEY,      toggletag,      &#123;.ui = 1 &lt;&lt; TAG&#125; &#125;,</span><br></code></pre></td></tr></table></figure>
<ul>
<li><code>#define MODKEY Mod1Mask</code>：这一行定义了<code>MODKEY</code>作为一个宏，它代表了键盘上的一个修饰键，通常是Alt键（Mod1）。在DWM中，这个修饰键通常与其他键组合使用，执行特定的操作。</li>
<li><code>TAGKEYS(KEY,TAG)</code>宏：这个宏是用来方便地定义与标签操作相关的四个快捷键。它接收两个参数，<code>KEY</code>代表你按下要绑定的按键（如<code>A</code>,
<code>B</code>,
<code>C</code>等），而<code>TAG</code>则是对应标签的索引（基于之前定义的标签数组）。宏展开后会生成四个键绑定规则，分别对应于查看标签、切换查看标签、将窗口移动到标签、以及切换窗口的标签状态。</li>
<li><code>&#123; MODKEY,                       KEY,      view,           &#123;.ui = 1 &lt;&lt; TAG&#125; &#125;</code>：按下<code>MODKEY</code>（通常是Alt）加上<code>KEY</code>，会将视图切换到对应标签（<code>TAG</code>）的工作区。<code>.ui = 1 &lt;&lt; TAG</code>计算出对应标签的位掩码，用于内部标记。</li>
<li><code>&#123; MODKEY|ControlMask,           KEY,      toggleview,     &#123;.ui = 1 &lt;&lt; TAG&#125; &#125;</code>：同时按下<code>MODKEY</code>+Ctrl+<code>KEY</code>，会切换当前工作区是否显示指定标签（<code>TAG</code>）的内容。如果当前工作区已显示该标签，则隐藏；如果未显示，则显示。</li>
<li><code>&#123; MODKEY|ShiftMask,             KEY,      tag,            &#123;.ui = 1 &lt;&lt; TAG&#125; &#125;</code>：按下<code>MODKEY</code>（Alt）+Shift+<code>KEY</code>，会将当前窗口移动到指定的标签（<code>TAG</code>）工作区。</li>
<li><code>&#123; MODKEY|ControlMask|ShiftMask, KEY,      toggletag,      &#123;.ui = 1 &lt;&lt; TAG&#125; &#125;</code>：同时按下<code>MODKEY</code>+Ctrl+Shift+<code>KEY</code>，会切换当前窗口是否属于指定的标签（<code>TAG</code>）。如果窗口已经属于该标签，则取消；如果不在，则添加。</li>
</ul>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs c"><span class="hljs-meta">#<span class="hljs-keyword">define</span> SHCMD(cmd) &#123; .v = (const char*[])&#123; <span class="hljs-string">&quot;/bin/sh&quot;</span>, <span class="hljs-string">&quot;-c&quot;</span>, cmd, NULL &#125; &#125;</span><br></code></pre></td></tr></table></figure>
<ul>
<li><code>#define SHCMD(cmd)</code>:
这是一个宏定义的开始，其中<code>cmd</code>是一个占位符，代表你想要执行的shell命令字符串。</li>
<li><code>&#123; .v = (const char*[])&#123; "/bin/sh", "-c", cmd, NULL &#125; &#125;</code>:
宏展开后生成的结构体初始化表达式。这个结构体通常用于向DWM指定一个可以执行shell命令的操作。具体来说：
<ul>
<li><code>.v</code>:
这是一个结构体的成员，指向一个字符指针数组。在DWM中，这样的结构体常用于定义按键绑定时执行的动作。</li>
<li><code>(const char*[])</code>:
定义了一个字符指针数组，数组中的每个元素都是一个指向字符串的指针。</li>
<li><code>"/bin/sh"</code>:
数组的第一个元素是<code>/bin/sh</code>，它指向Shell的路径。Shell是一个命令行解释器，可以执行命令。</li>
<li><code>"-c"</code>:
数组的第二个元素是<code>-c</code>，这是一个选项，告诉Shell接下来的参数是一个要执行的命令字符串。</li>
<li><code>cmd</code>:
数组的第三个元素是宏参数<code>cmd</code>，替换时会填入实际的shell命令字符串。</li>
<li><code>NULL</code>:
数组的末尾通常用<code>NULL</code>来表示结束，这是C语言中常见的做法。</li>
</ul></li>
</ul></li>
</ul>
<p><strong>命令(commands)</strong></p>
<ul>
<li><p><code>dmenumon</code>:
控制dmenu在哪个显示器上显示。<code>dmenucmd</code>:
dmenu的命令行参数。<code>termcmd</code>: 默认终端模拟器启动命令。</p>
<ul>
<li><code>char dmenumon[2] = "0";</code>：定义了一个字符数组，用来存储传递给dmenu的监视器编号。默认值为"0"，意味着dmenu将在主监视器上显示。</li>
<li><code>static const char *dmenucmd[]</code>：定义了启动dmenu的命令及其参数。dmenu是一个小巧的动态菜单工具，常用于快速启动程序。参数包括：
<ul>
<li><code>-m</code>, <code>dmenumon</code>:
指定在哪个显示器上显示dmenu。</li>
<li><code>-fn</code>, <code>dmenufont</code>: 指定dmenu使用的字体。</li>
<li><code>-nb</code>, <code>-nf</code>, <code>-sb</code>,
<code>-sf</code>:
分别设置背景色、前景色、选择条的背景色和前景色，颜色值由其他变量如<code>col_gray1</code>等定义。</li>
</ul></li>
<li><code>static const char *termcmd[]</code>：定义了启动终端（在这里是<code>st</code>，一个简单终端模拟器）的命令。</li>
</ul></li>
<li><p>这部分定义了一系列键盘快捷键，用于控制窗口管理和执行特定操作。快捷键由四个主要部分组成：修饰键（如<code>MODKEY</code>，一般映射为Alt或Super键）、普通键、功能（如<code>spawn</code>、<code>togglebar</code>）、以及该功能的具体参数。</p>
<p>例如：</p>
<ul>
<li><code>&#123; MODKEY, XK_p, spawn, &#123;.v = dmenucmd &#125; &#125;</code>：当按下<code>MODKEY</code>（假设是Alt）+
P时，执行dmenucmd数组定义的命令，即启动dmenu。</li>
<li><code>&#123; MODKEY|ShiftMask, XK_Return, spawn, &#123;.v = termcmd &#125; &#125;</code>：按下<code>MODKEY</code>+
Shift + Return时，启动终端模拟器。</li>
<li><code>&#123; MODKEY, XK_b, togglebar, &#123;0&#125; &#125;</code>：按下<code>MODKEY</code>+
B隐藏或显示窗口标题栏。</li>
<li>其他键绑定分别控制着聚焦、布局调整、窗口浮动、视图切换、标签页管理、退出DWM等功能。</li>
<li><code>spawn</code>在此处的作用是作为桥梁，将键盘事件转换为系统命令的执行，是实现快捷启动应用或其他系统操作的关键机制。</li>
</ul></li>
<li><p>按下<code>MODKEY</code>（通常是Alt键）+
<code>p</code>，会启动dmenu，用户可以在弹出的菜单中输入命令或选择程序进行执行。</p>
<p>按下<code>MODKEY</code>+ Shift +
回车，会打开一个新的终端窗口（使用<code>termcmd</code>定义的终端模拟器，如<code>suck</code>或更正为<code>st</code>）。</p>
<p>按下<code>MODKEY</code>+
<code>b</code>，可以隐藏或显示窗口管理器的状态栏。</p>
<p><code>MODKEY</code>+ <code>j</code>
下移焦点到下一个窗口，<code>MODKEY</code>+ <code>k</code>
上移焦点到上一个窗口。</p>
<p><code>MODKEY</code>+ <code>i</code>
增加主区域窗口数量，<code>MODKEY</code>+ <code>d</code>
减少主区域窗口数量。</p>
<p><code>MODKEY</code>+ <code>h</code>
缩小主区域宽度，<code>MODKEY</code>+ <code>l</code> 增大主区域宽度。</p>
<p>按下<code>MODKEY</code>+
回车，可以使当前窗口最大化（或恢复原大小）。</p>
<p><code>MODKEY</code>+ Tab 切换到下一个标签页。</p>
<p><code>MODKEY</code>+ Shift + <code>c</code>
关闭当前焦点所在的窗口。</p>
<p>分别按下<code>MODKEY</code>+
<code>t</code>、<code>f</code>、<code>m</code>，会切换到预设的三种布局：平铺、浮动、或单窗口全屏模式。</p>
<p><code>MODKEY</code>+ 空格 快速循环切换到下一个布局。</p>
<p><code>MODKEY</code>+ Shift + 空格 切换当前窗口的浮动状态。</p>
<p><code>MODKEY</code>+ <code>0</code>
查看所有标签页内容。<code>MODKEY</code>+ Shift + <code>0</code>
将当前窗口分配到所有标签页。</p>
<p><code>MODKEY</code>+ <code>,</code>
切换到左边的显示器，<code>MODKEY</code>+ <code>.</code>
切换到右边的显示器。</p>
<p><code>MODKEY</code>+ Shift + <code>,</code>
将当前窗口移动到左边的显示器，<code>MODKEY</code>+ Shift +
<code>.</code> 移动到右边的显示器。</p>
<p>分别按下<code>MODKEY</code>+
数字键1到9，可以快速切换到对应的标签页。</p>
<p><code>MODKEY</code>+ Shift + <code>q</code>
退出DWM窗口管理器。</p></li>
</ul>
<p><strong>按钮(buttons)</strong></p>
<ul>
<li>定义了鼠标点击事件与动作的映射，如在状态栏点击切换布局、在窗口标题上双击放大窗口等。
<ol type="1">
<li><code>&#123; ClkLtSymbol, 0, Button1, setlayout, &#123;0&#125; &#125;</code>:
<ul>
<li><strong>ClkLtSymbol</strong>:
操作发生于显示当前布局指示符的位置。</li>
<li><strong>0</strong>: 不需要额外的事件掩码。</li>
<li><strong>Button1</strong>: 鼠标左键。</li>
<li><strong>setlayout</strong>: 动作是切换布局。</li>
<li><code>&#123;0&#125;</code>:
传递给<code>setlayout</code>函数的参数为空，意味着切换到下一个布局。</li>
</ul></li>
<li><code>&#123; ClkLtSymbol, 0, Button3, setlayout, &#123;.v = &amp;layouts[2]&#125; &#125;</code>:
<ul>
<li>与上一条类似，但当点击鼠标右键时，直接切换到数组<code>layouts</code>中的第三个布局（数组索引从0开始，所以这是第3个布局）。</li>
</ul></li>
<li><code>&#123; ClkWinTitle, 0, Button2, zoom, &#123;0&#125; &#125;</code>:
<ul>
<li>在窗口标题上点击鼠标中键会执行<code>zoom</code>操作，通常是使窗口最大化或恢复原大小。</li>
</ul></li>
<li><code>&#123; ClkStatusText, 0, Button2, spawn, &#123;.v = termcmd &#125; &#125;</code>:
<ul>
<li>点击状态文本（可能显示时间、系统信息等）的鼠标中键会启动一个终端（由<code>termcmd</code>变量定义）。</li>
</ul></li>
<li><code>&#123; ClkClientWin, MODKEY, Button1, movemouse, &#123;0&#125; &#125;</code> 至
<code>&#123; ClkClientWin, MODKEY, Button3, resizemouse, &#123;0&#125; &#125;</code>:
<ul>
<li>当按下MODKEY（比如Alt键）并点击客户端窗口的不同按钮时，可以移动（Button1）或调整窗口大小（Button3）。</li>
</ul></li>
<li><code>&#123; ClkTagBar, 0, Button1, view, &#123;0&#125; &#125;</code> 至
<code>&#123; ClkTagBar, MODKEY, Button3, toggletag, &#123;0&#125; &#125;</code>:
<ul>
<li>在标签栏上操作，无修饰键点击左右键分别用于查看（view）或切换视图（toggleview）指定的工作区；按下MODKEY时点击左右键则是给工作区添加（tag）或移除（toggletag）标签。</li>
</ul></li>
</ol></li>
</ul>
<p>我的修改如下：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br></pre></td><td class="code"><pre><code class="hljs c"><span class="hljs-comment">/* See LICENSE file for copyright and license details. */</span><br><br><span class="hljs-comment">/* appearance */</span><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">unsigned</span> <span class="hljs-type">int</span> borderpx  = <span class="hljs-number">1</span>;        <span class="hljs-comment">/* border pixel of windows */</span><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">unsigned</span> <span class="hljs-type">int</span> snap      = <span class="hljs-number">32</span>;       <span class="hljs-comment">/* snap pixel */</span><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">int</span> showbar            = <span class="hljs-number">1</span>;        <span class="hljs-comment">/* 0 means no bar */</span><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">int</span> topbar             = <span class="hljs-number">1</span>;        <span class="hljs-comment">/* 0 means bottom bar */</span><br><span class="hljs-comment">// static const char *fonts[]          = &#123; &quot;monospace:size=10&quot; &#125;; </span><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">char</span> *fonts[]          = &#123; <span class="hljs-string">&quot;Hack Nerd Font Mono:size=10&quot;</span> &#125;;<br><span class="hljs-comment">// static const char dmenufont[]       = &quot;monospace:size=10&quot;;</span><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">char</span> dmenufont[]       = <span class="hljs-string">&quot;Hack Nerd Font Mono:size=10&quot;</span>;<br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">char</span> col_gray1[]       = <span class="hljs-string">&quot;#222222&quot;</span>;<br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">char</span> col_gray2[]       = <span class="hljs-string">&quot;#444444&quot;</span>;<br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">char</span> col_gray3[]       = <span class="hljs-string">&quot;#bbbbbb&quot;</span>;<br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">char</span> col_gray4[]       = <span class="hljs-string">&quot;#eeeeee&quot;</span>;<br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">char</span> col_cyan[]        = <span class="hljs-string">&quot;#005577&quot;</span>;<br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">char</span> *colors[][<span class="hljs-number">3</span>]      = &#123;<br>	<span class="hljs-comment">/*               fg         bg         border   */</span><br>	[SchemeNorm] = &#123; col_gray3, col_gray1, col_gray2 &#125;,<br>	[SchemeSel]  = &#123; col_gray4, col_cyan,  col_cyan  &#125;,<br>&#125;;<br><br><span class="hljs-comment">/* tagging */</span><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">char</span> *tags[] = &#123; <span class="hljs-string">&quot;1&quot;</span>, <span class="hljs-string">&quot;2&quot;</span>, <span class="hljs-string">&quot;3&quot;</span>, <span class="hljs-string">&quot;4&quot;</span>, <span class="hljs-string">&quot;5&quot;</span>, <span class="hljs-string">&quot;6&quot;</span>, <span class="hljs-string">&quot;7&quot;</span>, <span class="hljs-string">&quot;8&quot;</span>, <span class="hljs-string">&quot;9&quot;</span> &#125;;<br><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> Rule rules[] = &#123;<br>	<span class="hljs-comment">/* xprop(1):</span><br><span class="hljs-comment">	 *	WM_CLASS(STRING) = instance, class</span><br><span class="hljs-comment">	 *	WM_NAME(STRING) = title</span><br><span class="hljs-comment">	 */</span><br>	<span class="hljs-comment">/* class              instance    title       tags mask     isfloating   monitor */</span><br>	<span class="hljs-comment">// &#123; &quot;Gimp&quot;,           NULL,       NULL,       0,            1,           -1 &#125;,</span><br>	<span class="hljs-comment">// &#123; &quot;Firefox&quot;,        NULL,       NULL,       1 &lt;&lt; 8,       0,           -1 &#125;,</span><br>	&#123; <span class="hljs-string">&quot;wechat&quot;</span>          ,  <span class="hljs-literal">NULL</span>,       <span class="hljs-literal">NULL</span>    ,       <span class="hljs-number">1</span>,       <span class="hljs-number">0</span>,           <span class="hljs-number">-1</span> &#125;,<br>	&#123; <span class="hljs-string">&quot;QQ&quot;</span>              ,  <span class="hljs-literal">NULL</span>,       <span class="hljs-literal">NULL</span>    ,       <span class="hljs-number">1</span>,       <span class="hljs-number">0</span>,           <span class="hljs-number">-1</span> &#125;,<br>	&#123; <span class="hljs-string">&quot;ToDesk&quot;</span>          ,  <span class="hljs-literal">NULL</span>,       <span class="hljs-literal">NULL</span>    ,       <span class="hljs-number">1</span>,       <span class="hljs-number">0</span>,           <span class="hljs-number">-1</span> &#125;, <br>	&#123; <span class="hljs-string">&quot;Bytedance-feishu&quot;</span>,  <span class="hljs-literal">NULL</span>,       <span class="hljs-literal">NULL</span>    ,       <span class="hljs-number">1</span>,       <span class="hljs-number">0</span>,           <span class="hljs-number">-1</span> &#125;,<br>	&#123; <span class="hljs-string">&quot;Code&quot;</span>            ,  <span class="hljs-literal">NULL</span>,       <span class="hljs-literal">NULL</span>    ,  <span class="hljs-number">1</span> &lt;&lt; <span class="hljs-number">1</span>,       <span class="hljs-number">0</span>,           <span class="hljs-number">-1</span> &#125;,<br>	&#123; <span class="hljs-string">&quot;Google-chrome&quot;</span>   ,  <span class="hljs-literal">NULL</span>,       <span class="hljs-literal">NULL</span>    ,  <span class="hljs-number">1</span> &lt;&lt; <span class="hljs-number">2</span>,       <span class="hljs-number">0</span>,           <span class="hljs-number">-1</span> &#125;,<br>&#125;;<br><br><span class="hljs-comment">/* layout(s) */</span><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">float</span> mfact     = <span class="hljs-number">0.55</span>; <span class="hljs-comment">/* factor of master area size [0.05..0.95] */</span><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">int</span> nmaster     = <span class="hljs-number">1</span>;    <span class="hljs-comment">/* number of clients in master area */</span><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">int</span> resizehints = <span class="hljs-number">1</span>;    <span class="hljs-comment">/* 1 means respect size hints in tiled resizals */</span><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">int</span> lockfullscreen = <span class="hljs-number">1</span>; <span class="hljs-comment">/* 1 will force focus on the fullscreen window */</span><br><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> Layout layouts[] = &#123;<br>	<span class="hljs-comment">/* symbol     arrange function */</span><br>	&#123; <span class="hljs-string">&quot;[]=&quot;</span>,      tile &#125;,    <span class="hljs-comment">/* first entry is default */</span><br>	&#123; <span class="hljs-string">&quot;&gt;&lt;&gt;&quot;</span>,      <span class="hljs-literal">NULL</span> &#125;,    <span class="hljs-comment">/* no layout function means floating behavior */</span><br>	&#123; <span class="hljs-string">&quot;[M]&quot;</span>,      monocle &#125;,<br>&#125;;<br><br><span class="hljs-comment">/* key definitions */</span><br><span class="hljs-meta">#<span class="hljs-keyword">define</span> MODKEY Mod1Mask</span><br><span class="hljs-meta">#<span class="hljs-keyword">define</span> TAGKEYS(KEY,TAG) \</span><br><span class="hljs-meta">	&#123; MODKEY,                       KEY,      view,           &#123;.ui = 1 &lt;&lt; TAG&#125; &#125;, \</span><br><span class="hljs-meta">	&#123; MODKEY|ControlMask,           KEY,      toggleview,     &#123;.ui = 1 &lt;&lt; TAG&#125; &#125;, \</span><br><span class="hljs-meta">	&#123; MODKEY|ShiftMask,             KEY,      tag,            &#123;.ui = 1 &lt;&lt; TAG&#125; &#125;, \</span><br><span class="hljs-meta">	&#123; MODKEY|ControlMask|ShiftMask, KEY,      toggletag,      &#123;.ui = 1 &lt;&lt; TAG&#125; &#125;,</span><br><br><span class="hljs-comment">/* helper for spawning shell commands in the pre dwm-5.0 fashion */</span><br><span class="hljs-comment">// #define SHCMD(cmd) &#123; .v = (const char*[])&#123; &quot;/bin/sh&quot;, &quot;-c&quot;, cmd, NULL &#125; &#125;</span><br><span class="hljs-meta">#<span class="hljs-keyword">define</span> SHCMD(cmd) &#123; .v = (const char*[])&#123; <span class="hljs-string">&quot;/bin/bash&quot;</span>, <span class="hljs-string">&quot;-c&quot;</span>, cmd, NULL &#125; &#125;</span><br><br><span class="hljs-comment">/* commands */</span><br><span class="hljs-type">static</span> <span class="hljs-type">char</span> dmenumon[<span class="hljs-number">2</span>] = <span class="hljs-string">&quot;0&quot;</span>; <span class="hljs-comment">/* component of dmenucmd, manipulated in spawn() */</span><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">char</span> *dmenucmd[] = &#123; <span class="hljs-string">&quot;dmenu_run&quot;</span>, <span class="hljs-string">&quot;-m&quot;</span>, dmenumon, <span class="hljs-string">&quot;-fn&quot;</span>, dmenufont, <span class="hljs-string">&quot;-nb&quot;</span>, col_gray1, <span class="hljs-string">&quot;-nf&quot;</span>, col_gray3, <span class="hljs-string">&quot;-sb&quot;</span>, col_cyan, <span class="hljs-string">&quot;-sf&quot;</span>, col_gray4, <span class="hljs-literal">NULL</span> &#125;;<br><span class="hljs-type">static</span> <span class="hljs-type">const</span> <span class="hljs-type">char</span> *termcmd[]  = &#123; <span class="hljs-string">&quot;st&quot;</span>, <span class="hljs-literal">NULL</span> &#125;;<br><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> Key keys[] = &#123;<br>	<span class="hljs-comment">/* modifier                     key        function        argument */</span><br>	&#123; MODKEY,                       XK_p,      spawn,          &#123;.v = dmenucmd &#125; &#125;,<br>	&#123; MODKEY|ShiftMask,             XK_Return, spawn,          &#123;.v = termcmd &#125; &#125;,<br>	&#123; MODKEY,                       XK_b,      togglebar,      &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>	&#123; MODKEY,                       XK_j,      focusstack,     &#123;.i = +<span class="hljs-number">1</span> &#125; &#125;,<br>	&#123; MODKEY,                       XK_k,      focusstack,     &#123;.i = <span class="hljs-number">-1</span> &#125; &#125;,<br>	&#123; MODKEY,                       XK_i,      incnmaster,     &#123;.i = +<span class="hljs-number">1</span> &#125; &#125;,<br>	&#123; MODKEY,                       XK_d,      incnmaster,     &#123;.i = <span class="hljs-number">-1</span> &#125; &#125;,<br>	&#123; MODKEY,                       XK_h,      setmfact,       &#123;.f = <span class="hljs-number">-0.05</span>&#125; &#125;,<br>	&#123; MODKEY,                       XK_l,      setmfact,       &#123;.f = +<span class="hljs-number">0.05</span>&#125; &#125;,<br>	&#123; MODKEY,                       XK_Return, zoom,           &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>	&#123; MODKEY,                       XK_Tab,    view,           &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>	&#123; MODKEY|ShiftMask,             XK_c,      killclient,     &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>	&#123; MODKEY,                       XK_t,      setlayout,      &#123;.v = &amp;layouts[<span class="hljs-number">0</span>]&#125; &#125;,<br>	&#123; MODKEY,                       XK_f,      setlayout,      &#123;.v = &amp;layouts[<span class="hljs-number">1</span>]&#125; &#125;,<br>	&#123; MODKEY,                       XK_m,      setlayout,      &#123;.v = &amp;layouts[<span class="hljs-number">2</span>]&#125; &#125;,<br>	&#123; MODKEY,                       XK_space,  setlayout,      &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>	&#123; MODKEY|ShiftMask,             XK_space,  togglefloating, &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>	&#123; MODKEY,                       XK_0,      view,           &#123;.ui = ~<span class="hljs-number">0</span> &#125; &#125;,<br>	&#123; MODKEY|ShiftMask,             XK_0,      tag,            &#123;.ui = ~<span class="hljs-number">0</span> &#125; &#125;,<br>	&#123; MODKEY,                       XK_comma,  focusmon,       &#123;.i = <span class="hljs-number">-1</span> &#125; &#125;,<br>	&#123; MODKEY,                       XK_period, focusmon,       &#123;.i = +<span class="hljs-number">1</span> &#125; &#125;,<br>	&#123; MODKEY|ShiftMask,             XK_comma,  tagmon,         &#123;.i = <span class="hljs-number">-1</span> &#125; &#125;,<br>	&#123; MODKEY|ShiftMask,             XK_period, tagmon,         &#123;.i = +<span class="hljs-number">1</span> &#125; &#125;,<br>	TAGKEYS(                        XK_1,                      <span class="hljs-number">0</span>)<br>	TAGKEYS(                        XK_2,                      <span class="hljs-number">1</span>)<br>	TAGKEYS(                        XK_3,                      <span class="hljs-number">2</span>)<br>	TAGKEYS(                        XK_4,                      <span class="hljs-number">3</span>)<br>	TAGKEYS(                        XK_5,                      <span class="hljs-number">4</span>)<br>	TAGKEYS(                        XK_6,                      <span class="hljs-number">5</span>)<br>	TAGKEYS(                        XK_7,                      <span class="hljs-number">6</span>)<br>	TAGKEYS(                        XK_8,                      <span class="hljs-number">7</span>)<br>	TAGKEYS(                        XK_9,                      <span class="hljs-number">8</span>)<br>	&#123; MODKEY|ShiftMask,             XK_q,      quit,           &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>&#125;;<br><br><span class="hljs-comment">/* button definitions */</span><br><span class="hljs-comment">/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */</span><br><span class="hljs-type">static</span> <span class="hljs-type">const</span> Button buttons[] = &#123;<br>	<span class="hljs-comment">/* click                event mask      button          function        argument */</span><br>	&#123; ClkLtSymbol,          <span class="hljs-number">0</span>,              Button1,        setlayout,      &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>	&#123; ClkLtSymbol,          <span class="hljs-number">0</span>,              Button3,        setlayout,      &#123;.v = &amp;layouts[<span class="hljs-number">2</span>]&#125; &#125;,<br>	&#123; ClkWinTitle,          <span class="hljs-number">0</span>,              Button2,        zoom,           &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>	&#123; ClkStatusText,        <span class="hljs-number">0</span>,              Button2,        spawn,          &#123;.v = termcmd &#125; &#125;,<br>	&#123; ClkClientWin,         MODKEY,         Button1,        movemouse,      &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>	&#123; ClkClientWin,         MODKEY,         Button2,        togglefloating, &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>	&#123; ClkClientWin,         MODKEY,         Button3,        resizemouse,    &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>	&#123; ClkTagBar,            <span class="hljs-number">0</span>,              Button1,        view,           &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>	&#123; ClkTagBar,            <span class="hljs-number">0</span>,              Button3,        toggleview,     &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>	&#123; ClkTagBar,            MODKEY,         Button1,        tag,            &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>	&#123; ClkTagBar,            MODKEY,         Button3,        toggletag,      &#123;<span class="hljs-number">0</span>&#125; &#125;,<br>&#125;;<br></code></pre></td></tr></table></figure>
<h2 id="dmenu">dmenu</h2>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">git <span class="hljs-built_in">clone</span> https://git.suckless.org/dmenu<br></code></pre></td></tr></table></figure>
<p>dmenu接受标准输入（可以是echo，也可以是任何其他脚本的输出），用换行分隔，打开一个图形菜单，将前n项显示出来；用户可以输入并搜索，用户输入回车后，dmenu返回用户选择的菜单项；或者用户按Esc，dmenu什么也不返回；或者用户输入一个和任何菜单项都不匹配的字符串，dmenu返回这个字符串。</p>
<h2 id="st">st</h2>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">git <span class="hljs-built_in">clone</span> https://git.suckless.org/st<br></code></pre></td></tr></table></figure>
<h2 id="登录界面">登录界面</h2>
<h3 id="gdm3">gdm3</h3>
<p>ubuntu 22.04 使用 gdm3
作为显示管理器，也就是登录界面。我们需要给登录界面添加dwm的选项，在<code>/usr/share/xsessions</code>目录，新建<code>dwm.desktop</code>：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs bash">[Desktop Entry]<br>Encoding=UTF-8<br>Name=Dwm<br>Comment=Dynamic window manager<br>Exec=dwm<br>Icon=dwm<br>Type=XSession<br></code></pre></td></tr></table></figure>
<h3 id="startx">startx</h3>
<p>文字界面，系统资源占用少。</p>
<p>（1）修改文件<code>/etc/default/grub</code>：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment">#GRUB_CMDLINE_LINUX_DEFAULT=&quot;quiet splash&quot;</span><br>GRUB_CMDLINE_LINUX_DEFAULT=<span class="hljs-string">&quot;text&quot;</span><br></code></pre></td></tr></table></figure>
<p><code>quiet</code>抑制内核启动时的日志，<code>splash</code>启用开机加载进度条，<code>text</code>以文本模式启动后进入命令行登录界面。</p>
<p>还需要执行命令<code>sudo update-grub</code>。</p>
<p>（2）修改系统默认启动目标，将<code>graphical.target</code>修改为<code>multi-user.target</code>，这会开启一个文本登录界面：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs bash">sudo systemctl set-default multi-user.target<br><span class="hljs-comment">#sudo systemctl set-default graphical.target</span><br><span class="hljs-comment">#sudo systemctl get-default</span><br><span class="hljs-comment">#sudo systemctl list-units --type=target</span><br><span class="hljs-comment">#sudo systemctl show graphical.target</span><br></code></pre></td></tr></table></figure>
<p>（3）最后需要自定义X
Window会话的启动过程文件<code>~/.xinitrc</code>或<code>~/.xsession</code>，前者适用于直接<code>startx</code>启动，后者除了<code>startx</code>外还适用于Display
Manager启动。我既然选择命令行界面，当然选择修改<code>~/.xinitrc</code>（这也是dwm官方推荐）：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-built_in">exec</span> dwm<br></code></pre></td></tr></table></figure>
<h2 id="坑">坑</h2>
<h3
id="dwm不沿用gnome对于gtk应用的配置">dwm不沿用gnome对于gtk应用的配置</h3>
<p><a
target="_blank" rel="noopener" href="https://superuser.com/questions/391982/how-do-i-get-dwm-to-use-the-gnome-settings">How
do i get dwm to use the gnome settings</a>，I'm using dwm on Gentoo
GNU/Linux, but GTK+ applications launched from it don't load the correct
GNOME settings (fonts / styles). I've tried setting .gtkrc-2.0 and
gnome-session. I can't find gnome-settings-daemon on Gentoo, since it's
not in the package of the same name.</p>
<p>Does anybody know how to do this?</p>
<p><strong>Answer</strong>: Gnome-Session-Daemon needs a dbus session to
run. You do not specify how you are actually launching everything. The
link below goes into starting gnome-session and/or
Gnome-settings-Daemon.</p>
<p>http://www.gentoo.org/proj/en/desktop/gnome/howtos/gnome-2.16-upgrade.xml?style=printable</p>
<p>Are you using a Login Manager? Or just launching from xinitrc?</p>
<p>If you are using xinitrc, you can launch like this -- after using
something like lxappearance to set your gtk themes/icons.</p>
<figure class="highlight awk"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs awk">exec ck-launch-session dbus-launch --sh-syntax --<span class="hljs-keyword">exit</span>-with-session ~<span class="hljs-regexp">/bin/</span>startdwm<br></code></pre></td></tr></table></figure>
<p>With /bin/startdwm being an bash script</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-meta">#!/bin/bash</span><br><span class="hljs-comment">#this file is called by .xinitrc to start some nice apps for dwm</span><br><br>xrdb -merge ~/.Xresources &amp;<br><br>xfce4-power-manager &amp;<br><br>sh ~/.fehbg &amp;<br><br><span class="hljs-keyword">while</span> <span class="hljs-literal">true</span>; <span class="hljs-keyword">do</span><br>    xsetroot -name <span class="hljs-string">&quot;<span class="hljs-subst">$(date +<span class="hljs-string">&quot;%a %d.%m/%H:%M:%S&quot;</span>)</span> <span class="hljs-subst">$(df -h|grep root|awk &#x27;&#123;print $4&#125;&#x27;)</span>&quot;</span><br>    <span class="hljs-built_in">sleep</span> 1<br><span class="hljs-keyword">done</span> &amp;<br><br><span class="hljs-keyword">while</span> <span class="hljs-literal">true</span>; <span class="hljs-keyword">do</span><br>    dwm || <span class="hljs-built_in">exit</span><br><span class="hljs-keyword">done</span><br></code></pre></td></tr></table></figure>
<p>https://wiki.archlinux.org/index.php/Dwm#Using_dbus_with_dwm</p>

                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/myblog/categories/ubuntu/" class="category-chain-item">ubuntu</a>
  
  
    <span>></span>
    
  <a href="/myblog/categories/ubuntu/dwm/" class="category-chain-item">dwm</a>
  
  

  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/myblog/tags/dwm/" class="print-no-link">#dwm</a>
      
        <a href="/myblog/tags/window-manager/" class="print-no-link">#window-manager</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>ubuntu_windowmanager</div>
      <div>https://joelee-hit.github.io/joelee-hit.github.io/2024/05/16/ubuntu-windowmanager/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>joelee</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2024年5月16日</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>更新于</div>
          <div>2024年5月17日</div>
        </div>
      
      
        <div class="license-meta-item">
          <div>许可协议</div>
          <div>
            
              
              
                <a class="print-no-link" target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
                  <span class="hint--top hint--rounded" aria-label="BY - 署名">
                    <i class="iconfont icon-by"></i>
                  </span>
                </a>
              
            
          </div>
        </div>
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/myblog/2024/01/07/ubuntu%E4%B8%BB%E5%8A%9B%E7%B3%BB%E7%BB%9F%E6%97%A5%E5%B8%B8%E8%AE%B0%E5%BD%95/" title="ubuntu主力系统日常记录">
                        <span class="hidden-mobile">ubuntu主力系统日常记录</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
  
  
    <article id="comments" lazyload>
      
  <div id="valine"></div>
  <script type="text/javascript">
    Fluid.utils.loadComments('#valine', function() {
      Fluid.utils.createScript('https://lib.baomitu.com/valine/1.5.1/Valine.min.js', function() {
        var options = Object.assign(
          {"appId":"UU4TJ0JQzDgf0er5h2RfW8ve-gzGzoHsz","appKey":"px4eIsDZQBJRxIUkt6PCJpNH","path":"window.location.pathname","placeholder":null,"avatar":"robohash","meta":["nick","mail","link"],"requiredFields":[],"pageSize":10,"lang":"zh-CN","highlight":false,"recordIP":false,"serverURLs":"","emojiCDN":null,"emojiMaps":null,"enableQQ":false},
          {
            el: "#valine",
            path: window.location.pathname
          }
        )
        new Valine(options);
        Fluid.utils.waitElementVisible('#valine .vcontent', () => {
          var imgSelector = '#valine .vcontent img:not(.vemoji)';
          Fluid.plugins.imageCaption(imgSelector);
          Fluid.plugins.fancyBox(imgSelector);
        })
      });
    });
  </script>
  <noscript>Please enable JavaScript to view the comments</noscript>


    </article>
  


          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="margin-left: -1rem">
    <div id="toc">
  <p class="toc-header">
    <i class="iconfont icon-list"></i>
    <span>目录</span>
  </p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
    </div>
  
  
    <div class="statistics">
  
  

  
    
      <span id="leancloud-site-pv-container" style="display: none">
        总访问 
        <span id="leancloud-site-pv"></span>
         次
      </span>
    
    
      <span id="leancloud-site-uv-container" style="display: none">
        总访客 
        <span id="leancloud-site-uv"></span>
         人
      </span>
    
    

  
</div>

  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.4/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/myblog/js/events.js" ></script>
<script  src="/myblog/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/myblog/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.20.1/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script defer src="/myblog/js/leancloud.js" ></script>

  <script  src="/myblog/js/local-search.js" ></script>

  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>





<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/myblog/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
